import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MessagesVO, MessagesForm, MessagesQuery } from '@/api/system/messages/types';

/**
 * 查询对话记录列表
 * @param query
 * @returns {*}
 */

export const listMessages = (query?: MessagesQuery): AxiosPromise<MessagesVO[]> => {
  return request({
    url: '/system/messages/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询对话记录详细
 * @param messageId
 */
export const getMessages = (messageId: string | number): AxiosPromise<MessagesVO> => {
  return request({
    url: '/system/messages/' + messageId,
    method: 'get'
  });
};

/**
 * 新增对话记录
 * @param data
 */
export const addMessages = (data: MessagesForm) => {
  return request({
    url: '/system/messages',
    method: 'post',
    data: data
  });
};

/**
 * 修改对话记录
 * @param data
 */
export const updateMessages = (data: MessagesForm) => {
  return request({
    url: '/system/messages',
    method: 'put',
    data: data
  });
};

/**
 * 删除对话记录
 * @param messageId
 */
export const delMessages = (messageId: string | number | Array<string | number>) => {
  return request({
    url: '/system/messages/' + messageId,
    method: 'delete'
  });
};
